Skip to content

⚡ Bolt: [성능 개선] 반복 호출되는 함수 외부로 불변 문자열 및 해시 연산 이동 - #275

Closed
seonghobae wants to merge 1 commit into
masterfrom
bolt/hoist-static-strings-680193654362436127
Closed

⚡ Bolt: [성능 개선] 반복 호출되는 함수 외부로 불변 문자열 및 해시 연산 이동#275
seonghobae wants to merge 1 commit into
masterfrom
bolt/hoist-static-strings-680193654362436127

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

💡 What: process_dir 함수 내부에 있던 cssContent, css 불변 문자열 및 styleHash (SHA-256 연산) 값을 함수 외부 최상단 private val로 이동 (호이스팅)시켰습니다.
🎯 Why: process_dir 함수는 디렉토리 순회 중 반복적으로 호출되는 핫 패스(hot path)입니다. 내부에 거대한 정적 문자열 할당과 값비싼 SHA-256 암호화 해시 연산이 위치하면 매 호출마다 불필요한 메모리 할당과 CPU 오버헤드가 지속적으로 발생합니다.
📊 Impact: 디렉토리를 탐색할 때마다 발생하던 큰 문자열 재할당과 SHA-256 암호화 해시 계산을 단 1회(클래스 로딩 시)로 줄여 CPU 리소스 소모 및 GC(Garbage Collection) 부하를 획기적으로 개선합니다.
🔬 Measurement: 전체 테스트 스위트를 실행하여(export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 && ./gradlew clean test jacocoTestReport jacocoTestCoverageVerification --continue) 성능 최적화 후에도 기능 및 100% 코드 커버리지가 동일하게 유지됨을 확인하였습니다.


PR created automatically by Jules for task 680193654362436127 started by @seonghobae

Copilot AI review requested due to automatic review settings July 26, 2026 03:32
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the html4tree Kotlin CLI’s hot path (process_dir) by hoisting large invariant CSS strings and the SHA-256 style hash computation out of the repeatedly-invoked function and into file-level private vals, reducing per-directory allocations and CPU work.

Changes:

  • Hoisted cssContent, css, and styleHash from inside process_dir to top-level private val declarations.
  • Updated the Jules “bolt” learning log with an entry documenting this hoisting optimization.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/kotlin/html4tree/main.kt Hoists static CSS strings and SHA-256 hash computation out of process_dir to reduce repeated work.
.jules/bolt.md Adds a new performance-learning entry documenting the hoisting approach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +312 to 315
private val css = """
<style>
${cssContent} </style>
"""

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by canonical #363. The same stylesheet and SHA-256 work is hoisted there together with exact emitted-byte CSP correctness, an independent real generated-file digest regression, APA 7 doctoring, CHANGELOG.md, and fresh current-head CI/JaCoCo/Security/Semgrep evidence. No check or review from this duplicate head is reused.

@seonghobae seonghobae closed this Aug 5, 2026
@google-labs-jules

Copy link
Copy Markdown

Closing as superseded by canonical #363. The same stylesheet and SHA-256 work is hoisted there together with exact emitted-byte CSP correctness, an independent real generated-file digest regression, APA 7 doctoring, CHANGELOG.md, and fresh current-head CI/JaCoCo/Security/Semgrep evidence. No check or review from this duplicate head is reused.

Understood. Acknowledging that this work is superseded and stopping work on this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants